import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue';


// import Components from 'unplugin-vue-components/vite';
// import { AntDesignVueResolver } from 'unplugin-vue-components/resolvers';


// https://vitejs.dev/config/
export default defineConfig(({mode,command})=>{
   if(mode=='sit'){
    process.env.NODE_ENV='sit';
   }
  return {
    plugins: [

      vue(),

      // Components({  //ant-design-vue-3.2.x  按需
      //   resolvers: [
      //     AntDesignVueResolver({
      //       importStyle: false, // css in js
      //     }),
      //   ],
      // })

    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },

    base: "/",
    // base: "./",
    server: {
      port: 8088,
      host: "0.0.0.0"
    },

    module: {
      rules: [
        {
          // test: /\.(png|jpg|gif)$/i,
          test: /\.(jpg)$/i,
          use: [
            {
              loader: 'url-loader',
              options: {
                limit: false,
              },
            },
          ],
        },
      ],
    },



  }
})
